﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace DBService
{
	public partial class DlgAddProject : System.Windows.Forms.Form
	{
		public DlgAddProject()
		{
			this.InitializeComponent();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			try
			{
				string text = this.txtName.Text;
				string text2 = this.txtRacPath.Text;
				string text3 = this.txtRstPath.Text;
				string text4 = this.txtRmePath.Text;
				string text5 = this.txtInfo.Text;
				new DbProject(text, text5, text2, text3, text4).AddToDb(BimServerDB.Default);
				base.Close();
			}
			catch
			{
				MessageBox.Show("添加出错，请检查项目是否重名。");
			}
		}

		private void btnCancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void button1_Click_1(object sender, EventArgs e)
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
			openFileDialog.Filter = "Revit模型文件(*.rvt)|*.rvt;";
			openFileDialog.ShowDialog();
			this.txtRacPath.Text = openFileDialog.FileName;
		}

		private void button2_Click(object sender, EventArgs e)
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
			openFileDialog.Filter = "Revit模型文件(*.rvt)|*.rvt;";
			openFileDialog.ShowDialog();
			this.txtRstPath.Text = openFileDialog.FileName;
		}

		private void button3_Click(object sender, EventArgs e)
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
			openFileDialog.Filter = "Revit模型文件(*.rvt)|*.rvt;";
			openFileDialog.ShowDialog();
			this.txtRmePath.Text = openFileDialog.FileName;
		}

		private void txtName_TextChanged(object sender, EventArgs e)
		{
			if (this.txtName.Text == "")
			{
				this.btnOk.Enabled = false;
				return;
			}
			this.btnOk.Enabled = true;
		}
	}
}
